<template>
  <div>
    <el-table
      ref="tableDataTwo"
      :data="tableDataTwo"
      border
      style="width: 100%"
      @current-change="singLeElection"
    >
      <el-table-column label="请选择" width="65">
        <template v-slot="scopel">
          <el-radio v-model="multipleSelectionTwo" :label="scopel.$index">&nbsp;</el-radio>
        </template>
      </el-table-column>
      <el-table-column
        prop="date"
        label="部门名称"
        width="200"
      />
      <el-table-column
        prop="name"
        label="部门名称"
        width="200"
      />
      <el-table-column
        prop="address"
        label="部门名称"
        width="200"
      />
    </el-table>
    <span slot="footer" class="dialog-footer">
      <el-button @click="cancelTwo">取 消</el-button>
      <el-button type="primary" @click="determineTwo">确 定</el-button>
    </span>
  </div>
</template>

<script>
export default {
  data() {
    return {
      multipleSelectionTwo: [],
      tableDataTwo: [{
        date: '2016-05-02',
        name: '虎',
        address: '上海市普陀区金沙江路 1518 弄'
      }, {
        date: '2016-05-04',
        name: '王',
        address: '上海市普陀区金沙江路 1517 弄'
      }, {
        date: '2016-05-01',
        name: '小',
        address: '上海市普陀区金沙江路 1519 弄'
      }, {
        date: '2016-05-03',
        name: '小虎',
        address: '上海市普陀区金沙江路 1516 弄'
      }]
    }
  },
  methods: {
    // 取消
    cancelTwo() {},
    // 确定
    determineTwo() {
      console.log(this.multipleSelectionTwo)
      console.log(this.tableDataTwo[this.multipleSelectionTwo])
      this.$emit('Datafrom', this.tableDataTwo[this.multipleSelectionTwo])
      console.log(this.tableDataTwo[this.multipleSelectionTwo])
    },
    // 单选
    singLeElection(val) {
      console.log(val)
      this.multipleSelectionTwo = this.tableDataTwo.indexOf(item => item.data === val.data)
      console.log(this.multipleSelectionTwo)
    }
  }
}
</script>
